package com.exercise.family

import com.alibaba.fastjson.JSONObject
import com.fun.base.bean.RequestInfo
import com.fun.base.interfaces.IBase
import com.fun.frame.SourceCode
import com.fun.frame.httpclient.FanLibrary
import org.apache.http.client.methods.HttpGet
import org.apache.http.client.methods.HttpPost
import org.apache.http.client.methods.HttpRequestBase

class FunBase extends SourceCode implements IBase {


    public static final String HOST = "http://localhost:8080"
//    public static final String HOST = "http://10.60.0.50:8080"

    @Override
    HttpGet getGet(String s) {
        return FanLibrary.getHttpGet(HOST + s)
    }

    @Override
    HttpGet getGet(String s, JSONObject jsonObject) {
        return FanLibrary.getHttpGet(HOST + s, jsonObject)
    }

    @Override
    HttpPost getPost(String s) {
        return FanLibrary.getHttpPost(HOST + s)
    }

    @Override
    HttpPost getPost(String s, JSONObject jsonObject) {
        return FanLibrary.getHttpPost(HOST + s, jsonObject.toString())
    }

    @Override
    HttpPost getPost(String s, JSONObject jsonObject, File file) {
        return null
    }

    @Override
    JSONObject getResponse(HttpRequestBase httpRequestBase) {
        return FanLibrary.getHttpResponse(httpRequestBase)
    }

    @Override
    JSONObject getGetResponse(String s) {
        return getResponse(getGet(s))
    }

    @Override
    JSONObject getGetResponse(String s, JSONObject jsonObject) {
        return getResponse(getGet(s, jsonObject))
    }

    @Override
    JSONObject getPostResponse(String s) {
        return getResponse(getPost(s))
    }

    @Override
    JSONObject getPostResponse(String s, JSONObject jsonObject) {
        return getResponse(getPost(s, jsonObject))
    }

    @Override
    JSONObject getPostResponse(String s, JSONObject jsonObject, File file) {
        return null
    }

    @Override
    boolean isRight(JSONObject jsonObject) {
        return false
    }

    @Override
    int checkCode(JSONObject jsonObject, RequestInfo requestInfo) {
        return 0
    }

    @Override
    void login() {

    }

    @Override
    void setHeaders(HttpRequestBase httpRequestBase) {

    }

    @Override
    void handleResponseHeader(JSONObject jsonObject) {

    }

    @Override
    JSONObject getParams() {
        return null
    }

    @Override
    void init(JSONObject jsonObject) {

    }

    @Override
    void recordRequest() {

    }

    @Override
    HttpRequestBase getRequest() {
        return null
    }


    static void testOver() {
        FanLibrary.testOver()
    }
}
